package com.yenlien.traceyun.breed.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.breed.entity.Loss;
import com.yenlien.traceyun.breed.service.LossService;
import com.yenlien.traceyun.business.interceptor.DataAuth;
import com.yenlien.traceyun.webase.controller.BaseController;

/**
 * 报损控制层
 *
 * @author maybe
 * @date 2020年9月23日
 */
@RestController
@RequestMapping("/loss")
public class LossController extends BaseController {
    @Autowired
    private LossService lossService;

    //分页查询列表
    @DataAuth
    @RequestMapping(value = "/findByList", method = RequestMethod.POST)
    public Object findByList(@RequestBody JSONObject params) {
        Loss loss = new Loss();
        loss.setBreedId(params.getString("breedId"));
        loss.setPrincipalName(params.getString("searchName"));
        loss.setPage(params.getIntValue("page"));
        return buildPage(lossService.findByList(loss));
    }

    //新增报损
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public Object save(@RequestBody Loss loss) {
        lossService.save(loss);
        return success("success");
    }
}
